#作业1乘法表
# for in 1
list = []
for row in range(1, 10):
    for col in range(1, 10):
        if row >= col:
            if row >= col:
                # 为了对齐，加入变量a
                if row * col >= 10:
                    a = '   '
                else:
                    a = '    '
            print(col, '*', row, '=', row*col, end='{}'.format(a))
            # print('')
    print('')
print('='*300)

# for in 2
for row in range(9, 0, -1):
    for col in range(1, 10):
        if row >= col:
            # 为了对齐，加入变量a
            if row * col >= 10:
                a = '   '
            else:
                a = '    '
            print(col, '*', row, '=', row*col, end='{}'.format(a))
            # print('')
    print('')
print('='*300)

# for in 3
list = ['{}'.format('             ')]
for row in range(1, 10):
    print(list[0]*(9-row), end='')
    for col in range(9, 0, -1):
        if row >= col:
            # 为了对齐，加入变量a
            if row * col >= 10:
                a = '   '
            else:
                a = '    '
            print(col, '*', row, '=', row*col, end='{}'.format(a))
            # print()
    print('')
print('='*300)

# for in 4
list = ['{}'.format('             ')]
for row in range(9, 0, -1):
    print(list[0]*(9-row), end='')
    for col in range(9, 0, -1):
        if row >= col:
            # 为了对齐，加入变量a
            if row * col >= 10:
                a = '   '
            else:
                a = '    '
            print(col, '*', row, '=', row*col, end='{}'.format(a))
            # print()
    print('')
print('='*300)

# while 1
row = 1
while row < 10:
    col = 1
    while col <= row:
        print('{}*{}={:<3}'.format(col, row, col*row), end=' ')
        col += 1
    print('')
    row += 1
print('='*300)

# while 2
row = 9
while row > 0:
    col = 1
    while col <= row:
        print('{}*{}={:<3}'.format(col, row, col*row), end=' ')
        col += 1
    print('')
    row -= 1
print('='*300)

# while 3
row = 1
while row < 10:
    col = row
    list = []
    list.append('{}'.format('        '*(9-row)))
    print(list[0], end='')
    while col > 0:
        print('{}*{}={:<3}'.format(col, row, col*row), end=' ')
        col -= 1
    print('')
    row += 1
print('='*300)

# while 4
row = 9
while row > 0:
    col = row
    list = []
    list.append('{}'.format('        '*(9-row)))
    print(list[0], end='')
    while col > 0:
        print('{}*{}={:<3}'.format(col, row, col*row), end=' ')
        col -= 1
    print('')
    row -= 1
print('='*300)